refactor: decouple Serial API Message parsing and creation #7306
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR follows up on #7288, but this time for the Serial API message implementations.
The
Message
constructor signature was changed so it exclusively deals with constructing a message instance. Parsing binary payloads now happens in the staticfrom()
methods.List of breaking API changes:
[MessageName]Options
interfaces no longer extend another interface and now exclusively contain the message-specific properties required for constructing that particular instance[MessageName]Options & MessageBaseOptions
.MessageDeserializationOptions
interface and thegotDeserializationOptions
method no longer existDeserializingMessageConstructor
interface no longer existsMessageCreationOptions
type has been renamed toMessageOptions
from
method, which takes a pre-parsedMessageRaw
(message type, function type, binary payload) and theMessageParsingContext
. All Message implementations with a custom constructor are expected to implement thefrom
method aswell.To parse an arbitrary message buffer use
Message.parse(buffer, context)
.Message
methodsextractPayload
,getConstructor
,getMessageLength
andisComplete
were removed.Message.options
property was removedTXReport
object no longer has thenumRepeaters
property, as this was implied by the length of therepeaterNodeIds
array.ICommandClassContainer
interface was replaced with the newContainsCC
interface, which indicates that something contains a deserialized CC instance.Driver.computeNetCCPayloadSize
method now requires that the passed message instance contains a deserialized CC instance.Message.parse
no longer deserializes it automatically. This has to be done in a separate step.